package com.lzq.leetcode.real;

public class s69 {

    public int peakIndexInMountainArray(int[] arr) {
        int len = arr.length;
        int l = 0, r = len-1;

        while (l < r) {
            int mid = (l + r) / 2;

            if (mid > l && arr[mid - 1] < arr[mid]) {
                l = mid;
            } else if (mid < r && arr[mid] > arr[mid+1]) {
                r = mid;
            }
        }

        return arr[(l + r)/2];
    }

    public static void main(String[] args) {
        int[] arr = {0,1,0};
        System.out.println(new s69().peakIndexInMountainArray(arr));
    }
}
